package com.example.message.config;

import com.example.message.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class LoginInterceptorConfigurer implements WebMvcConfigurer {
    public void addInterceptors(InterceptorRegistry registry){
        System.out.println("addInterceptors");
        LoginInterceptor loginInterceptor = new LoginInterceptor();
        List<String> paths = new ArrayList<>();
        paths.add("/index.html");
        registry.addInterceptor((HandlerInterceptor)loginInterceptor).addPathPatterns(new String[]{"/**"}).excludePathPatterns(paths);
    }
}
